#include <iostream>
#include <string>
#include <set>
using namespace std;

int main()
{
	int n;
	string mapper[2] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
						 "22233344455566677778889999" };
	while (cin >> n && n)
	{
		string str, temp;
		set<string, less<string> > list;
		for (int i = 0; i < n; ++i)
		{
			cin >> str; temp = "";
			for (char ch : str)
			{
				if (ch != '-' && isalpha(ch))
					temp += mapper[1][toupper(ch) - 'A'];
				else if (ch != '-' && isalnum(ch))
					temp += ch;
			}
			temp.insert(temp.begin() + 3, '-');
			list.insert(temp);
		}
		for (string str : list) cout << str << endl;
		cout << endl;
	}
	return 0;
}

#include<iostream>
#include<vector>
using namespace std;
vector<int> vec;
int m,n;
void dfs(int index,int sum){
    if(sum>m)return ;
    if(sum==m){
        for(int i=0;i<vec.size()-1;i++){
            cout<<vec[i]<<" ";
        }cout<<vec[vec.size()-1]<<endl;
    }
    for(int i=index;i<=n&&sum+i<=m;i++){ //sum+i<=m剪枝
        vec.push_back(i);
        dfs(i+1,sum+i);
        vec.pop_back(); //回溯
    }
}
int main(){
    while(cin>>n>>m){
        dfs(1,0);
        vec.clear();
    }
    return 0;
}